<template>
  <div id="box">
    <div class="container">
      <div class="flip">
        <div class="digit" :data-digit-before="nub1" :data-digit-after="nub2">
          <!-- ::before -->
          <!-- onclick="this.classList.toggle('flipped')" -->
          <div class="card " onclick="this.classList.toggle('flipped')">
            <div class="card-face card-face-front">{{ nub1 }}</div>
            <div class="card-face card-face-back">{{ nub2 }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      nub1: "0",
      nub2: "5",
    };
  },
  methods: {
  },
};
</script>

<style scoped>
html,
body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: 0;
  padding: 0;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

#box {
  width: 100%;
  height: 500px;

  background-image: -moz-radial-gradient(#f4fab5, rgb(133, 206, 240));

  /* 考虑新旧样式兼容 */
  /* background-image: -webkit-gradient(
    radial,
    center center,
    0,
    center center,
    220,
    from(#f4fab5),
    to(rgb(133, 206, 240))
  );  //旧样式写法 */

  background-image: -webkit-radial-gradient(
    #f4fab5,
    rgb(133, 206, 240)
  ); /* new syntax */

  background-image: radial-gradient(#f4fab5, rgb(133, 206, 240));

  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;

  /* 字体样式练习 */
  font-family: -boxle-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 50px;
  line-height: 0;
}

.container * {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;

  cursor: default;
}

.flip {
  display: flex;
  margin-right: 4px;
  perspective: 1000px;
}

.digit {
  position: relative;

  width: 45px;
  height: 80px;

  box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.1);
}

.digit::before,
.digit::after {
  position: absolute;
  z-index: 0;

  display: flex;
  justify-content: center;

  width: 100%;
  height: 50%;
  overflow: hidden;
}

.digit::before {
  content: attr(data-digit-before);

  bottom: 0;
  align-items: flex-start;
}

.digit::after {
  content: attr(data-digit-after);

  top: 0;
  align-items: flex-end;
}

.card {
  position: relative;
  z-index: 1;

  width: 100%;
  height: 50%;

  transform-style: preserve-3d;

  transform-origin: bottom;

  transform: rotateX(0);

  transition: transform 0.7s ease-in-out;
}

.flipped {
  transform: rotateX(-180deg);
}

.card-face {
  position: absolute;

  display: flex;
  justify-content: center;

  width: 100%;
  height: 100%;
  overflow: hidden;

  backface-visibility: hidden;
}

.card-face-front {
  align-items: flex-end;
}

.card-face-back {
  align-items: flex-start;

  transform: rotateX(-180deg);
}

.digit::before,
.digit::after,
.card-face-front,
.card-face-back {
  background: white;
  color: black;
}

.digit,
.digit::before,
.digit::after,
.card,
.card-face {
  border-radius: 4px;
}

.digit::before,
.card-face-back {
  background: linear-gradient(0, #fafafa, #ccc 50%, #aaa);
  color: #212121;

  border-top: 1px solid black;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.digit::after,
.card-face-front {
  background: linear-gradient(0deg, #aaa, #bbb 50%, #f5f5f5);
  color: #212121;

  border-bottom: 1px solid black;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
</style>
